home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / Clouseau libs / ReadGeneva9Numbers.lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  5.4 KB  |  145 lines  |  [TEXT/MPS ]

  1. #########################################################################
  2. #########################################################################
  3. ##                     Copyright © Apple Computer, Inc. 1993-1997
  4. ##                                All rights reserved
  5. #########################################################################
  6. #########################################################################
  7. #    
  8. #    Library:        ReadGeneva9Numbers.lib
  9. #    
  10. #    Version:        2.1.4
  11. #    
  12. #    Description:    Contains tasks that retrieve the value of numbers on
  13. #                    the screen, if the font is Geneva 9. Used primarily by 
  14. #                    MemoryCP.lib for reading the settings not visible to VU.
  15. #            
  16. #                    Requires the VUAid 2.1 external tool.
  17. #            
  18. #    Contains:
  19. #        readGeneva9Number()
  20. #
  21. #    History:
  22. #        Date:        By:        Changes:
  23. #        01/11/93    SBR        Created
  24. #        09/04/95    SBR        Added this header for Radar 1273927
  25. #        06/01/96    SBR/MSO    Updated copyright header
  26. #        01/21/97    SBR        Updated copyright header.
  27. #    
  28. #########################################################################
  29. Libraries
  30.     "Additions.lib",
  31.     "Report.lib", 
  32.     "TargetControl.lib", 
  33.     "VUAid.lib", 
  34.     "VUAid.tool";
  35.  
  36. #########################################################################
  37. #    task        readGeneva9Number( LT, returnString, hilite, printValues, v_level)
  38. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  39. #    Description:    Reads a number on the screen in Geneva 9 plain using VUAid 2.0, 
  40. #                    for example in the Memory CP and About this Macintosh windows.
  41. #    Parameters:    LT:                Left Top pixel of the first digit in the number 
  42. #                                (screen relative)
  43. #                returnString:    Return number as string (e.g. if theNum > 32767)
  44. #                hilite:            Number of seconds to hilite each char 
  45. #                                as it is scanned (debugging) 
  46. #                printValues:    Println each recognized char and 
  47. #                                its checksum (debugging) 
  48. #    Returns:    successful: the integer which appears on screen
  49. #                unsuccessful: false (could not identify a character)
  50. #    Examples:    kDiskCacheSizeLT := { 284, 36 };
  51. #                readGeneva9Number( kDiskCacheSizeLT );
  52. #    Assumptions:    number is visible in front window
  53. #                    checksums are available for 1,2,4,8,16 and 32-bit depth 
  54. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  55. #    History:
  56. #        01/11/93    SBR        Created
  57. #        04/28/93    SBR        Added 2,4,16-bit checksums
  58. #        05/31/93    SBR        Added 32-bit checksums; checked 24 & 32-bit addressing with VUAid 2.0a7 
  59. #        06/25/93    SBR        Added returnString parameter for RAM Disk > 32767K 
  60. #########################################################################
  61. task ReadGeneva9Number(    LT, returnString := false, hilite := false, 
  62.                         printValues := false, v_level := 5 )
  63. begin
  64.     checkSums :=
  65.     {
  66.         { 1, {    { 21824,'1' },    { 24560,'2' },    { -480,'3' },    { -30816,'4' },    { -5600,'5' },
  67.                 { -29152,'6' },    { 27968,'7' },    { -25056,'8' },    { -29120,'9' },    { -21984,'0' },
  68.                 { 14736,'K' },    { -13056,'M' },    { 0,'' } }},
  69.         { 2, {    { 1530,'1' },    { -27610,'2' },    { -9874,'3' },    { -14536,'4' },    { -13570,'5' },
  70.                 { -32626,'6' },    { -14422,'7' },    { -24946,'8' },    { -24562,'9' },    { -26722,'0' },
  71.                 { 31800,'K' },    { 18432,'M' },    { 0,'' } }},
  72.         { 4, {    { 19170,'1' },    { 6194,'2' },    { 26654,'3' },    { 6584,'4' },    { 20414,'5' },
  73.                 { -7546,'6' },    { 14354,'7' },    { 9974,'8' },    { 10454,'9' },    { 2534,'0' },
  74.                 { 26520,'K' },    { -26206,'M' },    { 0,'' } }},
  75.         { 8, {    { 15554,'1' },    { 17338,'2' },    { 8922,'3' },    { -29582,'4' },    { 25242,'5' },
  76.                 { -17342,'6' },    { -1278,'7' },    { -29838,'8' },    { -29328,'9' },    { 31618,'0' },
  77.                 { -1532,'K' },    { -13262,'M' },    { 0,'' } }},
  78.         { 16, {    { -2920,'1' },    { 27304,'2' },    { 7272,'3' },    { 32056,'4' },    { -17176,'5' },
  79.                 { 13720,'6' },    { 22552,'7' },    { -200,'8' },    { -964,'9' },    { 5912,'0' },
  80.                 { -9964,'K' },    { 7608,'M' },    { -12516,'' } }},
  81.         { 32, {    { -2588,'1' },    { -7940,'2' },    { 17308,'3' },    { 1748,'4' },    { -31652,'5' },
  82.                 { 30564,'6' },    { -17628,'7' },    { 2516,'8' },    { 986,'9' },    { 14756,'0' },
  83.                 { -16866,'K' },    { 18324,'M' },    { -21462,'' } }}
  84.     };
  85.     charSize := { 7,8 };
  86.     RStatus("readGeneva9Number with LT = {LT}, hilite = {hilite}, printValues = {printValues}",v_level);
  87.     c1 := offset_list({0,0} + charSize,LT);
  88.     bitDepth := ensure_screen_depth({ 1,2,4,8,16,32 });
  89.     if not bitDepth
  90.     begin
  91.         return RIncomplete('readGeneva9Number: Can not set depth to one of { 1,2,4,8,16,32 }');
  92.     end;
  93.     else 
  94.         bitDepth := bitDepth[2];
  95.     
  96.     theNum := '';
  97.     endLoop := false;
  98.     i := 0;
  99.     while not done 
  100.     begin
  101.         hOffset := i * 6;                # offset to ith digit
  102.         c := {    hOffset + c1[1], c1[2], hOffset + c1[3], c1[4] };
  103.         
  104.         if hilite >= 0 
  105.         begin
  106.             VUAid('InvertScreenRect', { c[1], c[2], c[3], c[4] });
  107.             wait(hilite);
  108.             VUAid('InvertScreenRect', { c[1], c[2], c[3], c[4] });
  109.         end;
  110.         
  111.         chkSum := VUAid('CompareScreenRect', { c[1], c[2], c[3], c[4] });
  112.         nextChar := assoc(chkSum, assoc(bitDepth,checkSums));
  113.         if printValues
  114.             println "nextChar: {nextChar}   checkSum: {chkSum}";
  115.         if not (nextChar or theNum) 
  116.         begin
  117.             theNum := '';             # not a digit, 'K', 'M', or '' before the first digit
  118.             done := true;
  119.         end;
  120.         else if nextChar = 'K' or nextChar = 'M' or nextChar = ''
  121.             done := true;
  122.         else 
  123.         begin
  124.             theNum := theNum + nextChar;
  125.         end;
  126.         i := i + 1;
  127.     end;
  128.     
  129.     if not theNum 
  130.     begin
  131.         return RIncomplete("readGeneva9Number: bad number is '{theNum}'", v_level);
  132.     end;
  133.     
  134.     if returnString
  135.         rtnStrMsg := ' as a string';
  136.     else 
  137.     begin
  138.         theNum := strToNum(theNum);
  139.         rtnStrMsg := ' as an integer';
  140.     end;
  141.     RStatus("readGeneva9Number: returned {theNum}{rtnStrMsg}",v_level);
  142.     return theNum;
  143. end;
  144.  
  145.